package org.blogspot.t0yv0.marcalog.view

object Encoder {

  def url(x: String) =
    java.net.URLEncoder.encode(x, "UTF-8");

  def html(x: String) = {
    val buf = new StringBuffer();
    for (c <- x) {
      c match {
        case '&' => buf.append("&amp;");
        case '<' => buf.append("&lt;");
        case '>' => buf.append("&gt;");
        case '"' => buf.append("&quot;");
        case _   => buf.append(c);
      }
    }
    buf.toString;
  }

}
